home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 48 / PC Gamer IT CD 48 2-2.iso / Starsiege / tribesdemo.exe / Disk1 / data1.cab / Tribes_Demo / console.cs next >
Encoding:
Text File  |  1999-09-14  |  8.5 KB  |  340 lines

  1. //-----------------------------------
  2. //
  3. // Tribes startup
  4. //
  5. //-----------------------------------
  6.  
  7. // test if this is a dedicated server
  8. $dedicated = false;
  9.  
  10. $numExecFiles = 0;
  11.  
  12. for(%i = 1; $cargv[%i] != ""; %i++)
  13. {
  14.    if($cargv[%i] == "-mod")
  15.    {
  16.       %mod = $cargv[%i + 1];
  17.       %i++;
  18.       $modList = %mod @ " " @ $modList;
  19.         $modCount++;
  20.    }
  21.    else if($cargv[%i] == "-dedicated")
  22.    {
  23.       $dedicated = true;
  24.       %mission = $cargv[%i + 1];
  25.       if(%mission != "")
  26.       {
  27.          $HostMission = %mission;
  28.          %i++;
  29.       }
  30.    }
  31.    else if($cargv[%i] == "+exec")
  32.    {
  33.       $execFile[$numExecFiles] = $cargv[%i+1];
  34.       %i++;
  35.       $numExecFiles++;
  36.    }
  37.    else if($cargv[%i] == "+connect")
  38.    {
  39.       $connectAddress = $cargv[%i+1];
  40.       %i++;
  41.    }
  42.    else if($cargv[%i] == "+password")
  43.    {
  44.       $Server::JoinPassword = $cargv[%i+1];
  45.       $Server::Password = $cargv[%i+1];
  46.       %i++;
  47.    }
  48.    else if($cargv[%i] == "+record")
  49.    {
  50.       setupRecorderFile();
  51.    }
  52.    else if($cargv[%i] == "-host")
  53.    {
  54.       $HostMission = $cargv[%i+1];
  55.       $HostingGame = true;
  56.       %i++;
  57.    }
  58.    else if($cargv[%i] == "+maxplayers")
  59.    {
  60.       $HostPlayerCount = $cargv[%i+1];
  61.       %i++;
  62.    }
  63.    else if($cargv[%i] == "-edit")
  64.    {
  65.       $EditingMission = true;
  66.       $EditMission = $cargv[%i+1];
  67.       %i++;
  68.    }
  69. }
  70.  
  71. $WinConsoleEnabled = $dedicated;
  72. $Console::logBufferEnabled = !$dedicated; // turn off window scroll back
  73. $Console::Prompt = "% ";
  74.  
  75. if($dedicated)
  76. {
  77.    newServer();
  78.    focusServer();
  79. }
  80. else
  81. {
  82.    newClient();
  83.    focusClient();
  84.    $Console::LastLineTimeout = 0;
  85. }
  86.  
  87. function EvalSearchPath()
  88. {
  89.    // search path always contains the config directory
  90.    %searchPath = "config";
  91.    if($modList == "")
  92.       $modList = "base";
  93.    else
  94.    {
  95.       for(%i = 0; (%word = getWord($modList, %i)) != -1; %i++)
  96.          if(%word == "base")
  97.             break;
  98.       if(%word == -1)
  99.          $modList = $modList @ " base";
  100.    }
  101.    for(%i = 0; (%word = getWord($modList, %i)) != -1; %i++)
  102.    {
  103.       %addPath = %word @ ";" @ %word @ "\\missions;" @ %word @ 
  104.          "\\fonts;" @ %word @ "\\skins;" @ %word @ "\\voices;" @ %word @ "\\scripts";
  105.       %searchPath = %searchPath @ ";" @ %addPath;
  106.    }
  107.    %searchPath = %searchPath @ ";recordings;temp";
  108.    echo(%searchPath);
  109.  
  110.    $ConsoleWorld::DefaultSearchPath = %searchPath;
  111.  
  112.    // clear out the volumes:
  113.    for(%i = 0; isObject(%vol = "VoiceVolume" @ %i); %i++)
  114.       deleteObject(%vol);
  115.    for(%i = 0; isObject(%vol = "SkinVolume" @ %i); %i++)
  116.       deleteObject(%vol);
  117.  
  118.    // load all the volumes:
  119.    %file = File::findFirst("voices\\*.vol");
  120.    for(%i = 0; %file != ""; %file = File::findNext("voices\\*.vol"))
  121.       if(newObject("VoiceVolume" @ %i, SimVolume, %file))
  122.          %i++;
  123.  
  124.    %file = File::findFirst("skins\\*.vol");
  125.    for(%i = 0; %file != ""; %file = File::findNext("skins\\*.vol"))
  126.       if(newObject("SkinVolume" @ %i, SimVolume, %file))
  127.          %i++;
  128. }
  129.  
  130. function LoadModVolumes()
  131. {
  132.     // Load mod volumes in the order they were declared
  133.    for(%i = $modCount - 1; %i >= 0; %i--)
  134.    {
  135.         %word = getWord($modList, %i);
  136.         %vol = %word @ ".vol";
  137.         if (isFile(%word @ "\\" @ %vol))
  138.             newObject(%word @ "Volume", SimVolume, %vol);
  139.    }
  140. }
  141.  
  142. function ExecModScripts()
  143. {
  144.     // Exec mod scripts in the order they were declared
  145.    for(%i = $modCount - 1; %i >= 0; %i--)
  146.         exec(getWord($modList, %i) @ ".cs");
  147. }
  148.  
  149. //
  150. EvalSearchPath();
  151. LoadModVolumes();
  152. newObject(FontsVolume, SimVolume, "fonts.vol");
  153. newObject(ScriptsVolume, SimVolume, "scripts.vol");
  154. newObject(GuiVolume, SimVolume, "gui.vol");
  155. newObject(EditVolume, SimVolume, "edit.vol");
  156. newObject(EditorVolume, SimVolume, "editor.vol");
  157. newObject(DarkstarVolume, SimVolume, "darkstar.vol");
  158. newObject(InterfaceVolume, SimVolume, "interface.vol");
  159. newObject(ShellVolume, SimVolume, "shell.vol");
  160. newObject(ShellCommonVolume, SimVolume, "shellcommon.vol");
  161. newObject(EntitiesVolume, SimVolume, "entities.vol");
  162.  
  163. $Console::GFXFont = "interface.pft";
  164.  
  165. ////
  166. // Default volumes and tags
  167. //
  168.  
  169. exec("darkstar.strings.cs");
  170. exec("editor.strings.cs");
  171. exec("commonEditor.strings.cs");
  172. exec("esf.strings.cs");
  173. exec("fear.strings.cs");
  174. exec("help.strings.cs");
  175. exec("sfx.strings.cs");
  176. exec("banlist.cs");
  177.  
  178. //DEMOBUILD
  179. //exec("missionList.cs");
  180. exec("gui.cs");
  181. DemoBuild::Init();
  182.  
  183. exec("sae.cs");
  184. exec("client.cs");
  185. exec("server.cs");
  186. exec("tsDefaultMatProps.cs");
  187. exec("game.cs");
  188. exec("GenericTriggers.cs");
  189. exec("chatmenu.cs");
  190. exec("menu.cs");
  191. exec("observer.cs");
  192. exec("PlayerSetup.cs");
  193. exec("players.cs");
  194.  
  195. newObject("", IRCClient);
  196. exec("IRCClient.cs");
  197. exec("IRCServers.cs");
  198.  
  199. exec("Options.cs");
  200. exec("commander.cs");
  201.  
  202. ExecModScripts();
  203.  
  204. //
  205. // Default keys
  206. //
  207. bind(keyboard, make, control, o, to, "messageCanvasDevice(MainWindow, outline);");
  208. bind(keyboard, make, sysreq, to, "screenShot(MainWindow);");
  209. bind(keyboard, make, control, "-", to, "prevRes(MainWindow);");
  210. bind(keyboard, make, control, "+",  to, "nextRes(MainWindow);");
  211.  
  212.  
  213. // Load prefs and execute any autoexec commands...
  214. exec("clientDefaults.cs");
  215. exec("serverDefaults.cs");
  216. exec("clientPrefs.cs");
  217. exec("serverPrefs.cs");
  218. exec("config.cs");
  219. exec("badwords.cs");
  220. exec("autoexec.cs");
  221.  
  222. for(%i = 0; %i < $numExecFiles; %i++)
  223.    exec($execFile[%i]);
  224.  
  225. if($dedicated)
  226. {
  227.     if ($modCount && $MODInfo == "")
  228.         $MODInfo = "This server is running the following mods: " @ $modList;
  229.  
  230.    if($HostPlayerCount > 0)
  231.       $Server::MaxPlayers = $HostPlayerCount;
  232.    createServer($HostMission, True);
  233.     translateMasters();
  234.     echo("Dedicated Server Initialized");
  235. }
  236. else
  237. {
  238.    newObject(ConsoleScheduler, SimConsoleScheduler);
  239.  
  240.    // Create the main window with a gui in it
  241.    newObject(MainWindow, SimGui::Canvas, "Tribes", 640, 480, True, "512 384", "1024 768");
  242.  
  243.    exec("sound.cs");
  244.    inputActivate(keyboard0);
  245.    inputActivate(mouse0);
  246.  
  247.    if($pref::noIpx)
  248.       newObject(clientDelegate, FearCSDelegate, false, "IP", 0, "LOOPBACK", 0);
  249.    else
  250.       newObject(clientDelegate, FearCSDelegate, false, "IP", 0, "IPX", 0, "LOOPBACK", 0);
  251.    if(!$pref::lanOnly)
  252.        translateMasters();
  253.  
  254.    // Action map for flying cameras
  255.    exec("move.cs");
  256.    move();
  257.  
  258.    // Play the intro smacker file
  259.    setCursor(MainWindow, "Cur_Empty.bmp");
  260.    cursorOn(MainWindow);
  261.    //GuiLoadContentCtrl(MainWindow, "gui\\empty.gui");
  262.  
  263.    //all video initialization is now done in Options.cs
  264.    OptionsVideo::validate();
  265.    OptionsVideo::apply();
  266.  
  267.    if ($pref::cdMusic == "")
  268.        $pref::cdMusic = True;
  269.    if ($pref::cdVolume == "")
  270.        $pref::cdVolume = 0.5;
  271.    if ($pref::userCDOverride == "")
  272.        $pref::userCDOverride = False;
  273.    if ($pref::cdMusic || $pref::userCDOverrride)
  274.    {
  275.        newRedBook (CD, MainWindow);
  276.        rbSetVolume (CD, 1 - $pref::cdVolume);
  277.    }
  278.    if($HostingGame)
  279.    {
  280.       setCursor(MainWindow, "Cur_Arrow.bmp");
  281.       cursorOn(MainWindow);
  282.       if($HostPlayerCount > 0)
  283.          $Server::MaxPlayers = $HostPlayerCount;
  284.       createServer($HostMission, false);
  285.       $quitOnDisconnect = true;
  286.    }
  287.    else if($connectAddress != "")
  288.    {
  289.       $Server::Address = $connectAddress;
  290.       IRCLogin::AutoConnect();
  291.       setCursor(MainWindow, "Cur_Arrow.bmp");
  292.       cursorOn(MainWindow);
  293.       JoinGame();
  294.       $quitOnDisconnect = true;
  295.    }
  296.    else if($EditingMission)
  297.    {
  298.       setCursor(MainWindow, "Cur_Arrow.bmp");
  299.       cursorOn(MainWindow);
  300.       if($HostPlayerCount > 0)
  301.          $Server::MaxPlayers = $HostPlayerCount;
  302.       exec(editor);
  303.       
  304.       // check if creating or not
  305.       %missionFile = "missions\\" @ $EditMission @ ".mis";
  306.       if(File::FindFirst(%missionFile) == "")
  307.       {
  308.          GuiLoadContentCtrl(MainWindow, "gui\\mainmenu.gui");
  309.          $NewMissionName = $EditMission;
  310.          exec(newmission);
  311.       }
  312.       else
  313.          createServer($EditMission, false);
  314.       $quitOnDisconnect = false;
  315.    }
  316.    else
  317.    {
  318.       //translate all master server addressess - this function will eventually call startTheGame()
  319.       if($pref::quickstart)
  320.       {
  321.          GuiLoadContentCtrl(MainWindow, "gui\\mainmenu.gui");
  322.          Quickstart();
  323.           translateMasters();
  324.       }
  325.       else
  326.       {
  327. //         if (!$pref::skipIntro)
  328. //           GuiLoadContentCtrl(MainWindow, "gui\\intro.gui");
  329. //         else
  330.              startMainMenuScreen();
  331.       }
  332.  
  333.       //autologin to the irc client
  334.       IRCLogin::AutoConnect();
  335.    }
  336.     echo("Client Initialized");
  337. }
  338.  
  339.  
  340.